package com.itheima.dubbo.web;

import com.itheima.dubbo.com.itheima.dubbo.UserFace;
import com.itheima.dubbo.com.itheima.dubbo.pojo.User;

import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("user")
public class UserController {

//    @DubboReference(timeout = 3000)
//    @DubboReference(version = "2.0.0")
//    @DubboReference(retries = 1)
//    @DubboReference(loadbalance = "random")
    @DubboReference(check = false)
    private UserFace userFace;


    @GetMapping("hello")
    public String hello(String name) {
        RpcContext.getContext().setAttachment("index", "x");
        return userFace.hello(name);
    }

    @GetMapping("userByUser")
    public User userByUser() {
        User user = User.builder().id(11).age(23).name("songxiaodi").build();
        return userFace.findByUser(user);
    }
}
